home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
manchest.lha
/
MANCHESTER
/
manchester
/
4.1
/
keepCursorInView.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
4KB
|
122 lines
" NAME keepCursorInView
AUTHOR Bernard Horan <bernard@is.morgan.com>
CONTRIBUTOR Bernard Horan <bernard@is.morgan.com>
FUNCTION Changes to DialogView to keep cursor in view
ST-VERSIONS 4.1
PREREQUISITES
CONFLICTS
DISTRIBUTION global
VERSION 2.0
DATE September 1992
SUMMARY In versions prior to 4.0, Smalltalk contained
methods to keep the cursor in a view (i.e. a window), forcing a
single-thread dialogue. This changes file adds extra methods to
controller to offer that facility again. An extra instance variable
('modal') has been added to the class DialogController to set
'modalness'. This change set now forces fillInTheBlank and yesNo
windows to be modal. The changes to enforce this are trivial, and are
contained in the method 'open' The change works OK on Macs in single
and multifinder, however under OpenWindows it's best to have the
clickSelect option for window selection. BH, 25/9/92"!
'From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992 on 25 September 1992 at 7:29:18 am'!
!DialogView methodsFor: 'interaction'!
open
" Interact with the user. "
"Default to modal dialog.
Bernard Horan, 25 September 1992"
self openType: #dialog modal: true!
openType: windowType modal: aBoolean
" Interact with the user. "
"If aBoolean is true, then keep the cursor in the view.
Bernard Horan, 25 September 1992"
| borderWidth wrapper topView box |
borderWidth := 2.
wrapper := BorderedWrapper on: self.
wrapper border: (Border width: borderWidth).
topView := ScheduledWindow new.
topView component: wrapper.
topView controller: (DialogController new modal: aBoolean).
topView model: self closeChannel.
box := wrapper preferredBounds.
box := box
align: box center
with: WindowSensor cursorPoint.
topView openTransientIn: box type: windowType! !
StandardSystemController subclass: #DialogController
instanceVariableNames: 'modal '
classVariableNames: ''
poolDictionaries: ''
category: 'Interface-Dialogs'!
DialogController comment:
'Class DialogController keeps control until the model answers true to the message value.
In addition, it keeps the cursor in the view if the variable modal is set to true.
Bernard Horan, 25 September 1992
'!
!DialogController methodsFor: 'initialize-release'!
initialize
"Initialize the receiver.
bernard Horan, 25 September 1992"
super initialize.
self modal: false! !
!DialogController methodsFor: 'accessing'!
modal
"Bernard Horan, 25 September 1992"
^modal!
modal: aBoolean
"Bernard Horan, 25 September 1992"
modal := aBoolean! !
!DialogController methodsFor: 'control defaults'!
isControlActive
"Answer true as long as the dialog is not finished."
"Also, make sure that the cursor is kept in the view if the modal flag is true.
Bernard Horan, 25 September 1992"
self isFinished ifTrue: [^false].
self modal ifTrue: [ [self viewHasCursor] whileFalse:[self keepCursorInView]].
^true! !
DialogController organization changeFromString: '(''initialize-release'' #initialize)
(''accessing'' #modal #modal: #restartAfterError #shutdownBecauseOfError)
(''control defaults'' #close #controlActivity #controlInitialize #controlTerminate #isControlActive)
(''private'' #isFinished)
'!
!Controller methodsFor: 'cursor'!
keepCursorIn: aRectangle
"Bernard Horan, 25 September 1992"
| aPoint curPt |
aPoint := ((curPt := self sensor cursorPoint) max: aRectangle origin)
min: aRectangle corner.
aPoint = curPt ifFalse: [self sensor cursorPoint: aPoint]!
keepCursorInView
"Bernard Horan, 25 September 1992"
^self keepCursorIn: (view bounds insetBy: (0@0 extent: 1@1))! !